package com.ruoyi.web.controller.common;


import com.ruoyi.system.domain.supe.PlatformCoupon;
import com.ruoyi.system.domain.zhuangxiumain.shopMain.PreferentialCard;
import com.ruoyi.system.service.zhaungxiuservice.shopService.PlatformCouponService;
import com.ruoyi.system.service.zhaungxiuservice.shopService.PreferentialCardService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/***
 * 定时任务
 * 赵德健
 * **/
@Component
public class ClearDataJob {

//    private static final Logger logger = LoggerFactory.getLogger(ClearDataJob.class);
//
//    @Resource
//    private PreferentialCardService preferentialCardService;
//
//    @Resource
//    private PlatformCouponService PlatformCouponService;
//
////    @Scheduled(cron = "0 * * * * ?")
//    private void clearDataJob(){
//        logger.info("---------定时任务开始执行---------"+new SimpleDateFormat("HH:mm:ss").format(new Date()));
//        clearData(preferentialCardService);
//        couponData(PlatformCouponService);
//        logger.info("---------定时任务执行成功---------"+new  SimpleDateFormat("HH:mm:ss").format(new Date()));
//
//    }
//
//    private static void clearData(PreferentialCardService preferentialCardService){
//        try {
//            //设置日期格式
//            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            // new Date()为获取当前系统时间
//            String  s =  df.format(new Date());
//
//            logger.info("当前时间s是------："+s);
//            Date date = df.parse(s);
//            long time = date.getTime()/1000;
//            logger.info("当前时间戳ts是-------"+time);
//            PreferentialCard preferentialCard = new PreferentialCard();
//            preferentialCard.setPreferentialTime(date);
//            preferentialCardService.updateState(preferentialCard);
//            logger.info("商家更新成功！");
//        }catch (Exception e){
//            logger.error("清楚失败"+e.getMessage());
//        }
//    }
//
//    private static void couponData(PlatformCouponService platformCouponService){
//        try {
//            //设置日期格式
//            SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//            // new Date()为获取当前系统时间
//            String  s =  df.format(new Date());
//
//            logger.info("当前时间s是------："+s);
//            Date date = df.parse(s);
//            long time = date.getTime()/1000;
//            logger.info("当前时间戳ts是-------"+time);
//
//            PlatformCoupon platformCoupon = new PlatformCoupon();
//            platformCoupon.setPlatformTimeEnd(date);
//            platformCouponService.updateStateCou(platformCoupon);
//            logger.info("平台更新成功！");
//        }catch (Exception e){
//            logger.error("清楚失败"+e.getMessage());
//        }
//    }



}
